# geometry.two_d.base -- Base class for two-dimensional graphics objects
#
# Copyright (c) 2000, V.Kelson and M.Bakker
#

from numpy import *
import types
import exceptions

class Geometry2d:
	"""Base class for two-dimensional geometry objects.

	All geometry classes are derived from this class.
	All methods are abstract and should be overloaded in derived classes.
	A number of optional methods are defined for future use; it is not yet
	required to overload these methods. Exceptions are thrown if any method
	is called that is not implemented.

	Two-dimensional coordinate pairs are passed as XY objects and normally
	have the name 'pt' in the code. 'TRUE' values are returned as 0 (zero).
	"""
	# REQUIRED methods (throw exceptions if not implemented)
	def isOnBoundary(self,pt,tol=0.0):
		"""Check if pt is on boundary NOT IMPLEMENTED

		Returns TRUE if pt is within 'tol' of the boundary of the object"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.isOnBoundary()')
	def isInWidth(self,pt):
		"""Checks if pt is within width of line NOT IMPLEMENTED

		Returns TRUE if pt is within the width of the line defining the object.
		width is an attribute of objects consisting of lines"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.isInWidth()')
	def isInArea(self,pt):
		"""Checks if pt is in area NOT IMPLEMENTED

		Returns TRUE if pt is inside the object.
		Exists only for objects that have an inside area, such as a Circle or Polygon"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.isInArea()')
	def circumCircle(self):
		"""Calculates circumscribing circle NOT IMPLEMENTED

		Returns the circumscribing circle of the geometry as a Circle object"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.circumCircle()')
	def map(self,pt):
		"""Calculates Big Z NOT IMPLEMENTED

		Returns mapped, complex coordinates (the Big Z) for the object"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.map()')
	def bbox(self,tol=0.0):
		"""Calculates horizontal bounding box NOT IMPLEMENTED

		Returns a rectangle, oriented along the x-axis that bounds the geometry as a Rectangle object"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.bbox()')
	##################
	# OPTIONAL methods
	##################
	def draw(self,canvas=None):
		"""(optional method)

		Draws the object on the canvas (if provided)"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.draw()')
	def erase(self,canvas=None):
		"""(optional method)

		Erases the object from the canvas (if provided) """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.erase()')
	def select(self):
		"""(optional method)

		Selects the feature """ 
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.select()')
	def deselect(self):
		"""(optional method)

		Deselects the feature """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.deselect()')
	def click(self,event):
		"""(optional method)

		Callback (optional) for mouse clicks"""
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.click()')
	def doubleClick(self,event):
		"""(optional method)

		Callback (optional) for mouse double-clicks """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.doubleClick()')
	def rightClick(self,event):
		"""(optional method)

		Callback (optional) for mouse right-clicks """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.rightClick()')
	def mouseDrag(self,event):
		"""(optional method)

		Callback (optional) for mouse drags """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.mouseDrag()')
	def mouseMove(self,event):
		"""(optional method)

		Callback (optional) for mouse moves """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.mouseMove()')
	def distance2(self,pt):
		"""(optional method)

		Returns the square of the shortest distance from pt to the object """
		raise UnimplementedMethodException(1,'Must overload geometry.two_d.base.distance2()')
